package djboom.materials.core {
	import djboom.materials.events.BitmapDataCoreEvent;

	import org.casalib.events.LoadEvent;
	import org.casalib.load.SwfLoad;

	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.events.EventDispatcher;

	/**
	 * Менеджер визуальных элементов интерфейса.
	 * <br>
	 * 
	 * @author DJ BooM 
	 * @since 25.03.2010
	 * 
	 */

	public class BitmapDataCore extends EventDispatcher {

		// ----------------------------------------------------------------------------
		// Константы класса.
		// ----------------------------------------------------------------------------

		public static const LABEL_COMPLETE:String = "complete";

		public static const PAGE_INDEX:String = "bitmapdata.IndexPage";

		public static const COMMON_INTERFACE:String = "bitmapdata.CommonInterface";		public static const MODAL_WINDOW_TITLE:String = "bitmapdata.ModalWindowTitle";

		public static const BUTTON_EXIT:String = "bitmapdata.buttons.CloseWork";		public static const AUTOBUTTON:String = "bitmapdata.buttons.AutoButton";

		public static const PAGE_AUTHORS:String = "bitmapdata.PageAuthors";

		public static const PAGE_INFORMATION:String = "bitmapdata.PageInformation";		public static const PAGE_TASKS:String = "bitmapdata.PageTasks";		public static const PAGE_CONCEPTS:String = "bitmapdata.PageConcepts";

		public static const INSTRUCTION:String = "bitmapdata.Instruction";

		public static const WORK1_PAGE1_TEXT:String = "bitmapdata.Work1Page1Text";

		public static const WORK1_SAMPLE1:String = "bitmapdata.Work1Sample1";		public static const WORK1_SAMPLE2:String = "bitmapdata.Work1Sample2";		public static const WORK1_SAMPLE3:String = "bitmapdata.Work1Sample3";		public static const WORK1_SAMPLE4:String = "bitmapdata.Work1Sample4";		public static const WORK1_SAMPLE5:String = "bitmapdata.Work1Sample5";		public static const WORK1_SAMPLE6:String = "bitmapdata.Work1Sample6";

		public static const WORK1_SAMPLE1_WORK:String = "bitmapdata.Work1Sample1Work";		public static const WORK1_SAMPLE2_WORK:String = "bitmapdata.Work1Sample2Work";		public static const WORK1_SAMPLE3_WORK:String = "bitmapdata.Work1Sample3Work";		public static const WORK1_SAMPLE4_WORK:String = "bitmapdata.Work1Sample4Work";		public static const WORK1_SAMPLE5_WORK:String = "bitmapdata.Work1Sample5Work";		public static const WORK1_SAMPLE6_WORK:String = "bitmapdata.Work1Sample6Work";
		public static const WORK1_TABLEDATA:String = "bitmapdata.TableDataWork1";

		public static const SCALE:String = "bitmapdata.Scale";		public static const SCALE_STAGE:String = "bitmapdata.ScaleStage";		public static const SCALE_BUTTON_RESET:String = "bitmapdata.ScaleButtonReset";		public static const SCALE_BUTTON_TARA:String = "bitmapdata.ScaleButtonTara";

		/**
		 * Работа 2.
		 * 
		 */

		public static const WORK2_TABLEDATA:String = "TableDataWork2";
		public static const WORK2_PAGE1_TEXT:String = "work2.page1.Text";
		public static const WORK2_PAGE2_TEXT:String = "work2.page2.Text";

		public static const WORK2_SAMPLE1:String = "work2.Sample1";		public static const WORK2_SAMPLE2:String = "work2.Sample2";		public static const WORK2_SAMPLE3:String = "work2.Sample3";

		public static const WORK2_SAMPLE_MATERIAL1:String = "work2.sample1.Material";		public static const WORK2_SAMPLE_MATERIAL2:String = "work2.sample2.Material";		public static const WORK2_SAMPLE_MATERIAL3:String = "work2.sample3.Material";

		public static const WORK2_WEIGHT1:String = "work2.Weight1";		public static const WORK2_WEIGHT2:String = "work2.Weight2";		public static const WORK2_WEIGHT3:String = "work2.Weight3";
				public static const WORK2_HINT_1:String = "work2.Hint1";

		/**
		 * Работа 3.
		 * 
		 */

		public static const WORK3_TABLEDATA:String = "TableDataWork3";
		public static const WORK3_PAGE1_TEXT:String = "work3.page1.Text";
		public static const LE_CHATELIER_IMAGE:String = "lechatelier.Image";
		public static const MODAL_WINDOW_TITLE_BIG:String = "windowTitle.Big";

		// ----------------------------------------------------------------------------
		// Свойства класса.
		// ----------------------------------------------------------------------------

		private static var _libraryLoad:SwfLoad;

		// ----------------------------------------------------------------------------
		// Конструктор.
		// ----------------------------------------------------------------------------

		public function BitmapDataCore() {
			init();
		}	 

		// ----------------------------------------------------------------------------
		// Методы класса.
		// ----------------------------------------------------------------------------

		private function init():void {
			_libraryLoad = new SwfLoad("library.swf");
			_libraryLoad.addEventListener(LoadEvent.COMPLETE, interfaceComplete);			
			_libraryLoad.start();
		}

		private function interfaceComplete(event:LoadEvent):void {
			dispatchEvent(new BitmapDataCoreEvent(BitmapDataCoreEvent.COMPLETE));
		}

		// ----------------------------------------------------------------------------
		// Публичные методы.
		// ----------------------------------------------------------------------------

		public static function getBitmapData(className:String):BitmapData {
			return _libraryLoad.createClassByName(className, [0, 0]);
		}

		public static function getMovieClip(className:String):MovieClip {
			return _libraryLoad.createClassByName(className);
		}
	}
}
